@using System.Globalization
@model LocalizationPartViewModel

<style asp-src="~/OrchardCore.ContentLocalization/Styles/contentLocalization.min.css" debug-src="~/OrchardCore.ContentLocalization/Styles/contentLocalization.css"></style>

<input asp-for="LocalizationSet" type="hidden" />
<input asp-for="Culture" type="hidden" />
<div class="form-group content-localization" id="localizationPartEdit">
    <div class="card">
        <div class="card-header" id="contentLocalizationToggle">
            <button class="d-flex align-items-center justify-content-between btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#contentLocalizationCard" aria-expanded="true" aria-controls="collapseOne">
                @T["Current Culture: {1} | {0}", Model.CultureInfo.Name, Model.CultureInfo.DisplayName]
                <i class="fa fa-angle-down"></i>
            </button>
        </div>

        <div id="contentLocalizationCard" class="collapse" aria-labelledby="contentLocalizationToggle" data-parent="#localizationPartEdit">
            <div class="card-body">
                @if (!Model.ContentItemCultures.Any())
                {
                    <p>@T["Your site does not have any cultures. Current System culture is {1} | {0}", CultureInfo.InstalledUICulture.Name, CultureInfo.InstalledUICulture.DisplayName]</p>
                    <p><a asp-route-area="OrchardCore.Settings" asp-controller="Admin" asp-action="Index" asp-route-groupId = "localization">@T["Add or remove supported cultures for the site"]</a></p>
                }
                else
                {
                    @if (!string.IsNullOrEmpty(Model.LocalizationSet))
                    {
                        <div class="list-group">
                            @foreach (var culture in Model.ContentItemCultures)
                            {
                                if (!string.IsNullOrEmpty(culture.ContentItemId))
                                {
                                    <a class="list-group-item list-group-item-action" asp-action="Edit" asp-controller="Admin" asp-route-area="OrchardCore.Contents" asp-route-contentItemId="@culture.ContentItemId" title=@T["Edit {0}", culture.Culture.DisplayName]><i class="fa fa-edit"></i> @culture.Culture.DisplayName | @culture.Culture.Name </a>
                                }
                                else
                                {
                                    <a class="list-group-item list-group-item-action" itemprop="UnsafeUrl" asp-action="Localize" asp-controller="Admin" asp-route-area="OrchardCore.ContentLocalization" asp-route-contentItemId="@Model.LocalizationPart.ContentItem.ContentItemId" asp-route-targetCulture="@culture.Culture.Name" title=@T["Create {0}", culture.Culture.DisplayName]><i class="fa fa-plus"></i> @culture.Culture.DisplayName | @culture.Culture.Name</a>
                                }
                            }
                        </div>
                    }
                    else
                    {
                        @T["Please save your content item before creating localizations"]
                    }
                }
            </div>
        </div>
    </div>
</div>
